package com.firebird.app.kotlin.stock.trend.adapter

import android.view.View
import android.view.ViewGroup
import androidx.viewpager.widget.PagerAdapter


/**
 * 欢迎页面中的ViewPger 适配器
 * @author ljk
 * @date   2019年10月5日
 */
class NewsTouTiaoViewPagerAdapter(private val viewList: List<View>?) : PagerAdapter() {
    override fun getCount(): Int {
        return viewList?.size ?: 0
    }

    override fun isViewFromObject(arg0: View, arg1: Any): Boolean {
        return arg0 === arg1
    }

    override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
        container.removeView(viewList!![position])
    }

    override fun instantiateItem(container: ViewGroup, position: Int): Any {
        container.addView(viewList!![position])
        return viewList[position]
    }

}